<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>事件</title>
</head>
<body>
   <img id="img" src="img/3.jpg"/>
   <br>
   <button id="up" onclick="up()">上一张</button>
   <button id="down" onclick="down()">下一张</button>
</body>
<script>
    function up() {
        let img = document.getElementById("img");
        img.setAttribute("src","img/3.jpg");
    }

    function down() {
        let img = document.getElementById("img");
        img.setAttribute("src","img/4.jpg");
    }
</script>
</html>